#!/bin/bash
# @see https://help.aliyun.com/zh/ecs/use-cases/manually-deploy-mysql-on-an-ecs-instance-that-runs-centos
# 1. 更新YUM源
sudo rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm
# 2. 安装MySQL
sudo yum -y install mysql-community-server --enablerepo=mysql80-community --nogpgcheck
# 3. 查看版本号
mysql -V

# 4.1 配置 mysql，启动并设置开机自启动MySQL服务
sudo systemctl start mysqld
sudo systemctl enable mysqld

# 4.2 获取并记录root用户的初始密码
sudo grep 'temporary password' /var/log/mysqld.log

# sudo mysql_secure_installation 重置root密码
